<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>站内信管理</title> <#include "/WEB-INF/content/module-index.html">
<script type="text/javascript">

function handlerFormatter(value,rowData,rowIndex){
	if(rowData.tpl_id=='${map.ticketgivingsmstemplid}'){
		return "<span>默认模板</span>";
	}
	if(rowData.check_status=="SUCCESS"){
		return "<a href='javascript:doit(\""+rowData.tpl_id+"\",\""+rowData.tpl_content+"\")'>设为默认模板</a>";
	}
}

function doit(tpl_id,content){
	if(content.indexOf("{username}")==-1){
		top.showMsg("模板不合法，未找到昵称的匹配符{username}");
		return;
	}
	if(content.indexOf("{number}")==-1){
		top.showMsg("模板不合法，未找到票劵数量的匹配符{number}");
		return;
	}
	if(content.indexOf("{url}")==-1){
		top.showMsg("模板不合法，未找到APP下载地址的匹配符{url}");
		return;
	}
	if(confirm("你确定要将它设置为默认模板吗？")){
		$.ajax({
			url:"${request.contextPath}/base/parameter/update",
			async:false,
			data:{
				"name":"ticketgivingsmstemplid",
				"value":tpl_id
			},
			success:function(data){
				if(data.state){
					alert("设置成功,请关闭本选项卡重新加载");
				}
			}
		});
	}
}
</script>
<style>
a.btn-border{
	border: 1px solid #ccc;
}
</style>
</head>
<body>
<body class="easyui-layout">
	<div region="center" style="padding: 5px; background:#eee;">
		<table id="grid" class="easyui-datagrid" align="center" url="query" idField="tpl_id" rownumbers="true" striped="true" fitColumns="true" fit="true" pagination="true" singleSelect="true" toolbar="#toolbar">
			<thead>
				<tr>
					<th field="tpl_content" width="20">模板内容</th>
					<th field="check_status" width="10">审核状态</th>
					<th field="reason" width="10" align='center'>未通过原因</th>
					<th field="handler" width="10" formatter="handlerFormatter">操作</th>
				</tr>
			</thead>
		</table>
	</div>
</body>
</body>

</html>